<!--
 * @Author: lirl
 * @Date: 2024-08-02 10:15:42
 * @Description: 空状态组件
-->
<template>
  <div class="empty-container">
    <div class="empty-image" :style="imageStyle">
      <img
        alt="empty picture"
        :src="imageUrl"
        ondragstart="return false"
      >
    </div>
    <div v-if="description" class="empty-description">
      <p>{{ description }}</p>
    </div>
    <div v-if="$slots.default" class="empty-bottom">
      <slot></slot>
    </div>
  </div>
</template>
<script>

export default {
  name: 'Empty',
  props: {
    imageSrc: {
      type: String,
      default: ''
    },
    imageWith: {
      type: Number,
      default: 305
    },
    description: {
      type: String,
      default: '暂无数据'
    }
  },
  computed: {
    imageStyle() {
      return {
        width: `${this.imageWith}px`
      };
    },
    imageUrl() {
      return this.imageSrc || require('@/assets/images/empty.png');
    },
  }
};
</script>

<style lang="scss" scoped>
.empty-container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  text-align: center;
  box-sizing: border-box;
  padding: 95px 0;
  .empty-image {
    img {
      user-select: none;
      width: 100%;
      height: 100%;
      vertical-align: top;
      object-fit: contain;
    }
  }
  .empty-description {
    p {
      margin: 0;
      color:#999999;
      font-size: 14px;
      line-height: 22px;
    }
  }
}
</style>
